{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 安装GO\n",
    "\n",
    "1. 下载地址(国内镜像)\n",
    "\n",
    "   - https://studygolang.com/dl\n",
    "   - https://gomirrors.org/\n",
    "   \n",
    "2. 正常默认安装，[安装说明](https://docs.studygolang.com/doc/install)\n",
    "3. 将默认安装目录添加到 PATH\n",
    "   ```sh\n",
    "   export PATH=\"/usr/local/go/bin:$PATH\"\n",
    "   ```\n",
    "   \n",
    "4. 验证\n",
    "    ```sh\n",
    "    go version\n",
    "    ```\n",
    "\n",
    "## 配置环境变量\n",
    "\n",
    "### 查看go的详细信息\n",
    "通过`go env` 命令查看\n",
    "\n",
    "```sh\n",
    "→ go env\n",
    "GO111MODULE=\"on\"\n",
    "GOARCH=\"amd64\"\n",
    "GOBIN=\"\"\n",
    "GOCACHE=\"/Users/xxx/Library/Caches/go-build\"\n",
    "GOENV=\"/Users/xxx/Library/Application Support/go/env\"\n",
    "GOEXE=\"\"\n",
    "GOFLAGS=\"\"\n",
    "GOHOSTARCH=\"amd64\"\n",
    "GOHOSTOS=\"darwin\"\n",
    "GOOS=\"darwin\"\n",
    "GOPATH=\"/Users/xxx/go\"\n",
    "GOPRIVATE=\"\"\n",
    "GOPROXY=\"\"\n",
    "GOROOT=\"/usr/local/go\"\n",
    "GOSUMDB=\"sum.golang.org\"\n",
    "GOTMPDIR=\"\"\n",
    "GOTOOLDIR=\"/usr/local/go/pkg/tool/darwin_amd64\"\n",
    "GCCGO=\"gccgo\"\n",
    "AR=\"ar\"\n",
    "CC=\"clang\"\n",
    "CXX=\"clang++\"\n",
    "CGO_ENABLED=\"1\"\n",
    "GOMOD=\"/dev/null\"\n",
    "CGO_CFLAGS=\"-g -O2\"\n",
    "CGO_CPPFLAGS=\"\"\n",
    "CGO_CXXFLAGS=\"-g -O2\"\n",
    "CGO_FFLAGS=\"-g -O2\"\n",
    "CGO_LDFLAGS=\"-g -O2\"\n",
    "PKG_CONFIG=\"pkg-config\"\n",
    "GOGCCFLAGS=\"-fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/8j/t0wmqgyn4k18yyq3hk5lkgy80000gn/T/go-build942517272=/tmp/go-build -gno-record-gcc-switches -fno-common\"\n",
    "```\n",
    "\n",
    "### 修改默认的环境变量配置\n",
    "\n",
    "修改 `~/.bash_profile` 或者  `~/.zshrc`  \n",
    "**注意：千万不要把GOPATH设置成go的安装路径。**\n",
    "\n",
    "```sh\n",
    "# GOROOT\n",
    "# CentOS 中如下设置 GOROOT，看你安装的路径\n",
    "# export GOROOT=/usr/local/go\n",
    "# Mac OS 中通过命令行工具brew安装如下配置 GOROOT，通过pkg包安装的路径同上\n",
    "export GOROOT=/usr/local/Cellar/go/1.9/libexec\n",
    "\n",
    "# GOPATH root bin\n",
    "export GOBIN=$GOROOT/bin\n",
    "export PATH=$PATH:$GOBIN\n",
    "\n",
    "#GOPATH\n",
    "export GOPATH=$HOME/go\n",
    "\n",
    "# GOPATH bin\n",
    "export PATH=$PATH:$GOPATH/bin\n",
    "```\n",
    "\n",
    "使其立即生效\n",
    "\n",
    "```sh\n",
    "source /etc/profile\n",
    "```\n",
    "\n",
    "### 说明\n",
    "\n",
    "- `GOROOT`：安装目录（go语言安装目录）。\n",
    "- `GOPATH`：工程目录（自己工程项目目录）。\n",
    "- `GOBIN`：可执行文件目录。\n",
    "- `PATH`：将go可执行文件加入PATH中，使GO命令与我们编写的GO应用可以全局调用。\n",
    "\n",
    "GOPATH包含三个目录：bin、pkg、src。\n",
    "\n",
    "- src目录：源文件。\n",
    "- pkg目录：编译好的库文件，主要是*.a文件。\n",
    "- bin目录：可执行文件。\n",
    "\n",
    "**注意：千万不要把GOPATH设置成go的安装路径。**\n",
    "\n",
    "## 配置国内代理\n",
    "\n",
    "### Go 版本是 1.13 及以上\n",
    "\n",
    "```sh\n",
    "go env -w GO111MODULE=on\n",
    "go env -w GOPROXY=https://goproxy.io,direct\n",
    "\n",
    "# 设置不走 proxy 的私有仓库，多个用逗号相隔（可选）\n",
    "go env -w GOPRIVATE=*.corp.example.com\n",
    "\n",
    "# 设置不走 proxy 的私有组织（可选）\n",
    "go env -w GOPRIVATE=example.com/org_name\n",
    "```\n",
    "\n",
    "### Go 版本是 1.12 及以下\n",
    "\n",
    "```sh\n",
    "Bash (Linux or macOS)\n",
    "\n",
    "# 启用 Go Modules 功能\n",
    "export GO111MODULE=on\n",
    "# 配置 GOPROXY 环境变量\n",
    "export GOPROXY=https://goproxy.io\n",
    "```\n",
    "\n",
    "可以把上面的命令写到.profile或.bash_profile文件中长期生效。\n",
    "\n",
    "### PowerShell (Windows)\n",
    "\n",
    "```sh\n",
    "# 启用 Go Modules 功能\n",
    "$env:GO111MODULE=\"on\"\n",
    "# 配置 GOPROXY 环境变量\n",
    "$env:GOPROXY=\"https://goproxy.io\"\n",
    "```\n",
    "\n",
    "现在，当你构建或运行你的应用时，Go 将会通过 goproxy.io 获取依赖。更多信息请查看 [使用指引](https://goproxy.io/zh/docs/getting-started.html)。"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Jupyter 内核支持 - [Igo](https://github.com/yunabe/lgo)\n",
    "\n",
    "## 依赖环境\n",
    "\n",
    "- [Go版本 >= Go 1.8](https://golang.org/doc/install)\n",
    "- [安装ZMQ](http://zeromq.org/distro:debian)\n",
    "- [安装 jupyter](http://jupyter.readthedocs.io/en/latest/install.html)\n",
    "- [安装pkg-config](https://www.freedesktop.org/wiki/Software/pkg-config/)\n",
    "\n",
    "## 安装\n",
    "\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.7"
  },
  "toc": {
   "base_numbering": 1,
   "nav_menu": {},
   "number_sections": true,
   "sideBar": true,
   "skip_h1_title": false,
   "title_cell": "Table of Contents",
   "title_sidebar": "Contents",
   "toc_cell": false,
   "toc_position": {},
   "toc_section_display": true,
   "toc_window_display": true
  },
  "varInspector": {
   "cols": {
    "lenName": 16,
    "lenType": 16,
    "lenVar": 40
   },
   "kernels_config": {
    "python": {
     "delete_cmd_postfix": "",
     "delete_cmd_prefix": "del ",
     "library": "var_list.py",
     "varRefreshCmd": "print(var_dic_list())"
    },
    "r": {
     "delete_cmd_postfix": ") ",
     "delete_cmd_prefix": "rm(",
     "library": "var_list.r",
     "varRefreshCmd": "cat(var_dic_list()) "
    }
   },
   "types_to_exclude": [
    "module",
    "function",
    "builtin_function_or_method",
    "instance",
    "_Feature"
   ],
   "window_display": false
  }
 },
 "nbformat": 4,
 "nbformat_minor": 4
}
